﻿using stdCall.MyAnimate;
using stdCall.Models;
using stdCall;

namespace stdCall.MyRandom
{
    /// <summary>
    /// 提供核心随机服务
    /// </summary>
    class RandomService
    {
        public static Student currentStudent;
        public static Student nextStudent;
        private StudentsManager studentManager = new StudentsManager();

        /// <summary>
        /// 点击random按钮触发，随机主函数，包括动画
        /// 先做当前学生Label的动画（做 AnimateService.animateNum次：获取随机学生，进行动画）
        /// 再做下一个学生Label的动画（做 AnimateService.animateNum次：Service.getAnimateService().animateNextResulted()）
        /// </summary>
        public void startRandom(){
            AnimateService animateService = new AnimateService();
            Student std = null;
            int num = AnimateService.animateNum;
            System.Collections.ArrayList stds = studentManager.getAllStudents();
            for (int i = 0; i < num; i++)
            {
                std = Caculator.getAPoorStdNum(stds);
                animateService.animateCurrentStd(std, i);
            }
            RandomService.currentStudent = std;
            RandomService.nextStudent=animateService.animateNextAndReturnStd();
        }
    }
}
